import chinaDataV from "./chinaGeo.js" //中国地图  只有轮廓
import provinceDataV from "./provinceGeo.js"//全部省份
const henan = require("./lib/410000.json")//只下载了河南的地级市数据  如需要更多 可自行下载


class dataV {
	constructor() {
		this.timer = ""
		
		// 中国地图于省份数据合在一起绘制
		chinaDataV.features=chinaDataV.features.concat(provinceDataV.features)
		this.chinaGeo = chinaDataV
		// 只有省份数据
		this.provinceGeo = provinceDataV
		// 省的对应的编号
		this.provinceArea = proArr


	}
	// 单例方法
	static getInstace() {
		if (!this.instance) {
			this.instance = new dataV()
		}
		return this.instance

	}
	//数据
	chartsOption() {
		return {
			backgroundColor: '',
			title: {
				text: '全国地图大数据',
				subtext: '',
				x: 'center'
			},
			roam:false,
			center:[104.97, 37.71],
			tooltip: {
				trigger: 'item'
			},
			scaleLimit:{
				min:1,
				max:4
			},

			//配置属性
			series: [
				this.getMapCustomSet('数据','china',[],1.3)
				// this.getMapCustomSet('数据','province',[])
				
				
				
			]
		};
	}

	// 获取省的轮廓
	getProvinceGeoFromId(provinceName) {
		let findItem = this.provinceArea.find(function(a, b) {
			return a.name == provinceName

		})

		let dic = {
			option: {
				title: {
					text: '全国地图大数据',
					subtext: '',
					x: 'center'
				},
				tooltip: {
					trigger: 'item'
				},
				scaleLimit:{
					min:1,
					max:4
				},

				//配置属性
				series: [
					this.getMapCustomSet(findItem.name,findItem.id,[])]
			},
			dataV: henan



		}
		return dic





	}
	
	// 自定义地图 统一配置
	getMapCustomSet(name,map,data,zoom=1){
	let setDic=	{
			name: name,
			type: 'map',
			map: map,
			roam: true,
			zoom:1.3,
			select:{//点击后的效果
				itemStyle: {
					areaColor: "#0067FF",
					color:"#fff"
					
				},
				label:{
					show:true,
					areaColor: "#0067FF",
					color:"#fff"
				}
			},
			
			label: {
				normal: {
					show: true, //省份名称  
					formatter: '{b}',
					color:"#fff"
					
				},
				emphasis: {
					show: true,
					formatter: '{b}:{@name}',
					color:"#fff"
					
		
		
				}
			},
			itemStyle: {
				normal: {
					label: {
						show: true
					},
					areaColor:"#070A28",
					borderColor: '#40f1ff',
					borderWidth: 1,
					borderType:"dashed"
					
				},
				emphasis: {//高亮的效果
					areaColor: "#0067FF",
					borderColor: '#40f1ff',
					borderWidth: 1,
					shadowColor: '#40f1ff',
					shadowOffsetX: -1,
					shadowOffsetY: -1,
					label: {
						show: false
					}
				}
			},
			data:data //[{name:'河南省',value:22222}] //数据
		}
		let newSetDic={}
		Object.assign(newSetDic,setDic,{name,map,data,zoom})
		
		return newSetDic
		
		
	}


}

const proArr = [{
		"id": "710000",
		"name": "台湾省"
	},
	{
		"id": "130000",
		"name": "河北省"
	},
	{
		"id": "140000",
		"name": "山西省"
	},
	{
		"id": "150000",
		"name": "内蒙古自治区"
	},
	{
		"id": "210000",
		"name": "辽宁省"
	},
	{
		"id": "220000",
		"name": "吉林省"
	},
	{
		"id": "230000",
		"name": "黑龙江省"
	},
	{
		"id": "320000",
		"name": "江苏省"
	},
	{
		"id": "330000",
		"name": "浙江省"
	},
	{
		"id": "340000",
		"name": "安徽省"
	},
	{
		"id": "350000",
		"name": "福建省"
	},
	{
		"id": "360000",
		"name": "江西省"
	},
	{
		"id": "370000",
		"name": "山东省"
	},
	{
		"id": "410000",
		"name": "河南省"
	},
	{
		"id": "420000",
		"name": "湖北省"
	}, // 
	{
		"id": "430000",
		"name": "湖南省"
	},
	{
		"id": "440000",
		"name": "广东省"
	},
	{
		"id": "450000",
		"name": "广西壮族自治区"
	},
	{
		"id": "460000",
		"name": "海南省"
	},
	{
		"id": "510000",
		"name": "四川省"
	},
	{
		"id": "520000",
		"name": "贵州省"
	},
	{
		"id": "530000",
		"name": "云南省"
	},
	{
		"id": "540000",
		"name": "西藏自治区"
	},
	{
		"id": "610000",
		"name": "陕西省"
	},
	{
		"id": "620000",
		"name": "甘肃省"
	},
	{
		"id": "630000",
		"name": "青海省"
	},
	{
		"id": "640000",
		"name": "宁夏回族自治区"
	},
	{
		"id": "650000",
		"name": "新疆维吾尔自治区"
	},
	{
		"id": "110000",
		"name": "北京省"
	},
	{
		"id": "120000",
		"name": "天津省"
	},
	{
		"id": "310000",
		"name": "上海省"
	},
	{
		"id": "500000",
		"name": "重庆省"
	},
	{
		"id": "810000",
		"name": "香港省"
	},
	{
		"id": "820000",
		"name": "澳门省"
	}
]

export default dataV.getInstace()
